﻿<%@ Page Title="" Language="VB" MasterPageFile="~/admin/admin.master" AutoEventWireup="false" CodeFile="members.aspx.vb" Inherits="admin_members" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
    <div class="page-header">
        <h1>Members <small>
            <asp:Label ID="uniLabel" runat="server" Text=""></asp:Label></small></h1>
    </div>

    <div class="clearfix"></div>
    <div class="form-inline">
        <asp:HiddenField ID="UniID" runat="server" />
        <asp:TextBox ID="TextBox1" runat="server" CssClass="input-medium search-query" placeholder="Search"></asp:TextBox>
        <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
            DataSourceID="SqlDataSource2" DataTextField="UNIVERISTY_NAME" DataValueField="UNIVERISTY_NAME">
            <asp:ListItem></asp:ListItem>
        </asp:DropDownList>
        <asp:Button ID="Button1" runat="server" Text="Search" CssClass="btn" /> 
        <asp:HyperLink ID="HyperLink2" CssClass="btn btn-primary pull-right" runat="server" NavigateUrl="~/admin/members/add-member.aspx"><i class="icon-user"></i> New Member</asp:HyperLink>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
            SelectCommand="SELECT * FROM [UNIVERSITIES]"></asp:SqlDataSource>
    </div>
    <br />
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="table" 
            DataKeyNames="ID" GridLines="None" 
            EmptyDataText="No registered members yet" AllowPaging="False" 
            AllowSorting="False" EnablePersistedSelection="True">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="NAME & EMAIL" SortExpression="FIRST_NAME">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("FIRST_NAME") %>' ></asp:Label> 
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("LAST_NAME") %>'></asp:Label><br />
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("EMAIL") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
               <%-- <asp:BoundField DataField="FIRST_NAME" HeaderText="FIRST NAME" SortExpression="FIRST_NAME" />
                <asp:BoundField DataField="LAST_NAME" HeaderText="LAST NAME" SortExpression="LAST_NAME" />--%>
                <%--<asp:BoundField DataField="EMAIL" HeaderText="EMAIL" SortExpression="EMAIL" />--%>
                <asp:BoundField DataField="UNIVERISTY_NAME" HeaderText="INSTITUTION" 
                    SortExpression="UNIVERISTY_NAME" />
                <asp:TemplateField HeaderText="Action">
                    <ItemTemplate>
                        <asp:hyperlink ID="LinkButton1" cssclass="btn btn-info btn-small" runat="server" 
                            NavigateUrl='<%# "profile.aspx?id=" + Eval("ID").tostring %>'  ToolTip="view member details"><i class="icon-user"></i></asp:hyperlink>
                        <%--<asp:LinkButton ID="LinkButton22" cssclass="btn btn-danger btn-small" runat="server" CommandName="Delete"><i class="icon-remove"></i></asp:LinkButton>--%>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>        
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
            
            SelectCommand="SELECT MEMBERS.ID, MEMBERS.FIRST_NAME, MEMBERS.LAST_NAME, MEMBERS.EMAIL, MEMBERS.PHONE, MEMBERS.UNIVERSITY_ID, MEMBERS.STUDENT_ID, MEMBERS.CREATED_DATE, MEMBERS.SUBJECT_AREA, MEMBERS.YEAR_OF_STUDY, MEMBERS.DEGREE_TYPE, MEMBERS.CAREER_INTEREST, MEMBERS.GENDER, MEMBERS.ETHNICITY, MEMBERS.UK_CITIZEN, MEMBERS.AGE_GROUP, UNIVERSITIES.ID AS Expr1, UNIVERSITIES.UNIVERISTY_NAME FROM MEMBERS INNER JOIN UNIVERSITIES ON MEMBERS.UNIVERSITY_ID = UNIVERSITIES.ID WHERE (MEMBERS.FIRST_NAME LIKE '%' + @SEARCH + '%') OR (MEMBERS.LAST_NAME LIKE '%' + @SEARCH + '%') AND (UNIVERSITIES.UNIVERISTY_NAME LIKE '%' + @UNI)" 
            DeleteCommand="DELETE FROM [MEMBERS] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [MEMBERS] ([FIRST_NAME], [LAST_NAME], [EMAIL], [PHONE], [UNIVERSITY_ID], [STUDENT_ID], [CREATED_DATE], [SUBJECT_AREA], [YEAR_OF_STUDY], [DEGREE_TYPE], [CAREER_INTEREST], [GENDER], [ETHNICITY], [UK_CITIZEN], [AGE_GROUP]) VALUES (@FIRST_NAME, @LAST_NAME, @EMAIL, @PHONE, @UNIVERISTY_ID, @STUDENT_ID, @CREATED_DATE, @SUBJECT_AREA, @YEAR_OF_STUDY, @DEGREE_TYPE, @CAREER_INTEREST, @GENDER, @ETHNICITY, @UK_CITIZEN, @AGE_GROUP)"          
            UpdateCommand="UPDATE [MEMBERS] SET [FIRST_NAME] = @FIRST_NAME, [LAST_NAME] = @LAST_NAME, [EMAIL] = @EMAIL, [PHONE] = @PHONE, [UNIVERSITY_ID] = @UNIVERISTY_ID, [STUDENT_ID] = @STUDENT_ID, [CREATED_DATE] = @CREATED_DATE, [SUBJECT_AREA] = @SUBJECT_AREA, [YEAR_OF_STUDY] = @YEAR_OF_STUDY, [DEGREE_TYPE] = @DEGREE_TYPE, [CAREER_INTEREST] = @CAREER_INTEREST, [GENDER] = @GENDER, [ETHNICITY] = @ETHNICITY, [UK_CITIZEN] = @UK_CITIZEN, [AGE_GROUP] = @AGE_GROUP WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FIRST_NAME" Type="String" />
                <asp:Parameter Name="LAST_NAME" Type="String" />
                <asp:Parameter Name="EMAIL" Type="String" />
                <asp:Parameter Name="PHONE" Type="String" />
                <asp:Parameter Name="UNIVERISTY_ID" Type="Int32" />
                <asp:Parameter Name="STUDENT_ID" Type="String" />
                <asp:Parameter Name="CREATED_DATE" Type="DateTime" />
                <asp:Parameter Name="SUBJECT_AREA" Type="String" />
                <asp:Parameter Name="YEAR_OF_STUDY" Type="String" />
                <asp:Parameter Name="DEGREE_TYPE" Type="String" />
                <asp:Parameter Name="CAREER_INTEREST" Type="String" />
                <asp:Parameter Name="GENDER" Type="String" />
                <asp:Parameter Name="ETHNICITY" Type="String" />
                <asp:Parameter Name="UK_CITIZEN" Type="Boolean" />
                <asp:Parameter Name="AGE_GROUP" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="SEARCH" PropertyName="Text" ConvertEmptyStringToNull="false" />
                <asp:ControlParameter ControlID="DropDownList1" Name="UNI" ConvertEmptyStringToNull="false"
                    PropertyName="SelectedValue" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="FIRST_NAME" Type="String" />
                <asp:Parameter Name="LAST_NAME" Type="String" />
                <asp:Parameter Name="EMAIL" Type="String" />
                <asp:Parameter Name="PHONE" Type="String" />
                <asp:Parameter Name="UNIVERISTY_ID" Type="Int32" />
                <asp:Parameter Name="STUDENT_ID" Type="String" />
                <asp:Parameter Name="CREATED_DATE" Type="DateTime" />
                <asp:Parameter Name="SUBJECT_AREA" Type="String" />
                <asp:Parameter Name="YEAR_OF_STUDY" Type="String" />
                <asp:Parameter Name="DEGREE_TYPE" Type="String" />
                <asp:Parameter Name="CAREER_INTEREST" Type="String" />
                <asp:Parameter Name="GENDER" Type="String" />
                <asp:Parameter Name="ETHNICITY" Type="String" />
                <asp:Parameter Name="UK_CITIZEN" Type="Boolean" />
                <asp:Parameter Name="AGE_GROUP" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
            
            SelectCommand="SELECT MEMBERS.ID, MEMBERS.FIRST_NAME, MEMBERS.LAST_NAME, MEMBERS.EMAIL, MEMBERS.PHONE, MEMBERS.UNIVERSITY_ID, MEMBERS.STUDENT_ID, MEMBERS.CREATED_DATE, MEMBERS.SUBJECT_AREA, MEMBERS.YEAR_OF_STUDY, MEMBERS.DEGREE_TYPE, MEMBERS.CAREER_INTEREST, MEMBERS.GENDER, MEMBERS.ETHNICITY, MEMBERS.UK_CITIZEN, MEMBERS.AGE_GROUP, UNIVERSITIES.ID AS Expr1, UNIVERSITIES.UNIVERISTY_NAME FROM MEMBERS INNER JOIN UNIVERSITIES ON MEMBERS.UNIVERSITY_ID = UNIVERSITIES.ID WHERE (MEMBERS.FIRST_NAME LIKE '%' + @SEARCH + '%' OR MEMBERS.LAST_NAME LIKE '%' + @SEARCH + '%') AND (UNIVERSITIES.ID = @UNI)" 
            DeleteCommand="DELETE FROM [MEMBERS] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [MEMBERS] ([FIRST_NAME], [LAST_NAME], [EMAIL], [PHONE], [UNIVERSITY_ID], [STUDENT_ID], [CREATED_DATE], [SUBJECT_AREA], [YEAR_OF_STUDY], [DEGREE_TYPE], [CAREER_INTEREST], [GENDER], [ETHNICITY], [UK_CITIZEN], [AGE_GROUP]) VALUES (@FIRST_NAME, @LAST_NAME, @EMAIL, @PHONE, @UNIVERISTY_ID, @STUDENT_ID, @CREATED_DATE, @SUBJECT_AREA, @YEAR_OF_STUDY, @DEGREE_TYPE, @CAREER_INTEREST, @GENDER, @ETHNICITY, @UK_CITIZEN, @AGE_GROUP)"          
            
            UpdateCommand="UPDATE [MEMBERS] SET [FIRST_NAME] = @FIRST_NAME, [LAST_NAME] = @LAST_NAME, [EMAIL] = @EMAIL, [PHONE] = @PHONE, [UNIVERSITY_ID] = @UNIVERISTY_ID, [STUDENT_ID] = @STUDENT_ID, [CREATED_DATE] = @CREATED_DATE, [SUBJECT_AREA] = @SUBJECT_AREA, [YEAR_OF_STUDY] = @YEAR_OF_STUDY, [DEGREE_TYPE] = @DEGREE_TYPE, [CAREER_INTEREST] = @CAREER_INTEREST, [GENDER] = @GENDER, [ETHNICITY] = @ETHNICITY, [UK_CITIZEN] = @UK_CITIZEN, [AGE_GROUP] = @AGE_GROUP WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FIRST_NAME" Type="String" />
                <asp:Parameter Name="LAST_NAME" Type="String" />
                <asp:Parameter Name="EMAIL" Type="String" />
                <asp:Parameter Name="PHONE" Type="String" />
                <asp:Parameter Name="UNIVERISTY_ID" Type="Int32" />
                <asp:Parameter Name="STUDENT_ID" Type="String" />
                <asp:Parameter Name="CREATED_DATE" Type="DateTime" />
                <asp:Parameter Name="SUBJECT_AREA" Type="String" />
                <asp:Parameter Name="YEAR_OF_STUDY" Type="String" />
                <asp:Parameter Name="DEGREE_TYPE" Type="String" />
                <asp:Parameter Name="CAREER_INTEREST" Type="String" />
                <asp:Parameter Name="GENDER" Type="String" />
                <asp:Parameter Name="ETHNICITY" Type="String" />
                <asp:Parameter Name="UK_CITIZEN" Type="Boolean" />
                <asp:Parameter Name="AGE_GROUP" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="SEARCH" PropertyName="Text" ConvertEmptyStringToNull="false" />
                <asp:ControlParameter ControlID="UniID" Name="UNI" ConvertEmptyStringToNull="false"
                    PropertyName="Value" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="FIRST_NAME" Type="String" />
                <asp:Parameter Name="LAST_NAME" Type="String" />
                <asp:Parameter Name="EMAIL" Type="String" />
                <asp:Parameter Name="PHONE" Type="String" />
                <asp:Parameter Name="UNIVERISTY_ID" Type="Int32" />
                <asp:Parameter Name="STUDENT_ID" Type="String" />
                <asp:Parameter Name="CREATED_DATE" Type="DateTime" />
                <asp:Parameter Name="SUBJECT_AREA" Type="String" />
                <asp:Parameter Name="YEAR_OF_STUDY" Type="String" />
                <asp:Parameter Name="DEGREE_TYPE" Type="String" />
                <asp:Parameter Name="CAREER_INTEREST" Type="String" />
                <asp:Parameter Name="GENDER" Type="String" />
                <asp:Parameter Name="ETHNICITY" Type="String" />
                <asp:Parameter Name="UK_CITIZEN" Type="Boolean" />
                <asp:Parameter Name="AGE_GROUP" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>

